In [1]:
import pandas as pd
import oandapyV20
import oandapyV20.endpoints.trades as trades
import configparser
In [2]:
config = configparser.ConfigParser()
config.read('../config/config_v20.ini')
accountID = config['oanda']['account_id']
access_token = config['oanda']['api_key']
In [3]:
client = oandapyV20.API(access_token=access_token)
In [4]:
params ={
"instrument": "DE30_EUR,EUR_USD"
}
In [5]:
r = trades.TradesList(accountID=accountID, params=params)
In [6]:
client.request(r)
Out[6]:
In [7]:
print(r.response)
In [8]:
r = trades.OpenTrades(accountID)
In [9]:
client.request(r)
Out[9]:
In [10]:
r.response
Out[10]:
In [11]:
trade_id = r.response['trades'][0]['id']
In [12]:
r = trades.TradeDetails(accountID, tradeID=trade_id)
In [13]:
client.request(r)
Out[13]:
In [14]:
print(r.response)
In [15]:
data = {
"units": 100
}
In [16]:
r = trades.TradeClose(accountID, tradeID=trade_id)
In [17]:
client.request(r)
Out[17]: